*&---------------------------------------------------------------------*
*& 包含               ZFIU021_TOP
*&---------------------------------------------------------------------*
TABLES: EKKO,EKBE,ZFIT078_HEAD, ZFIT079_HEAD, ZFIT079_ITEM.
TABLES: SSCRFIELDS.


TYPES:
  BEGIN OF TY_INV_DATA, "此类型和excel模板发票数据字段一一对应
    ZFPHM  TYPE ZFIT078_HEAD-ZFPHM,
    ZHSJE  TYPE ZFIT078_HEAD-ZHSJE,
    ZHJSE  TYPE ZFIT078_HEAD-ZHJSE,
    ZBHSJE TYPE ZFIT078_HEAD-ZBHSJE,
    ZXFMC  TYPE ZFIT078_HEAD-ZXFMC,
  END OF TY_INV_DATA,

  BEGIN OF TY_GR_DATA, "此类型和excel模板收货数据字段一一对应
    SGTXT          TYPE ZFIT079_HEAD-SGTXT,
    LIFNR_AND_NAME TYPE TEXT100,
    EBELN          TYPE ZFIT079_ITEM-EBELN,
    EBELP          TYPE ZFIT079_ITEM-EBELP,

    ERFMG          TYPE ZFIT079_ITEM-ERFMG,
    ERFME          TYPE ZFIT079_ITEM-ERFME,
    WRBTR          TYPE ZFIT079_ITEM-WRBTR,
    WAERS          TYPE ZFIT079_ITEM-WAERS,
    MWSKZ          TYPE ZFIT079_ITEM-MWSKZ,
    ZFPSL          TYPE ZFIT079_ITEM-ZFPSL,
    ZFPSE          TYPE ZFIT079_ITEM-ZFPSE,
    MBLNR          TYPE ZFIT079_ITEM-MBLNR,
    MJAHR          TYPE ZFIT079_ITEM-MJAHR,
    ZEILE          TYPE ZFIT079_ITEM-ZEILE,
    SHEET_NO       TYPE ZFIT079_ITEM-SHEET_NO,
    COND_TYPE      TYPE ZFIT079_ITEM-COND_TYPE,

    BSART_AND_TEXT TYPE TEXT100,
    WERKS_AND_NAME TYPE TEXT100,
    CHARG          TYPE ZFIT079_ITEM-CHARG,
    MATNR          TYPE ZFIT079_ITEM-MATNR,
    TXZ01          TYPE ZFIT079_ITEM-TXZ01,
    SHKZG          TYPE ZFIT079_ITEM-SHKZG,
  END OF TY_GR_DATA,

  BEGIN OF TY_UPLOAD_DATA, "此类型和上传excel模板收货数据字段一一对应,排除T_COLOR
    ZHBBS          TYPE ZFIT078_HEAD-ZFPHM,

    ZFPHM          TYPE ZFIT078_HEAD-ZFPHM,
    ZHSJE          TYPE ZFIT078_HEAD-ZHSJE,
    ZHJSE          TYPE ZFIT078_HEAD-ZHJSE,
    ZBHSJE         TYPE ZFIT078_HEAD-ZBHSJE,

    SGTXT          TYPE ZFIT079_HEAD-SGTXT,
    LIFNR_AND_NAME TYPE TEXT100,
    EBELN          TYPE ZFIT079_ITEM-EBELN,
    EBELP          TYPE ZFIT079_ITEM-EBELP,

    ERFMG          TYPE ZFIT079_ITEM-ERFMG,
    ERFME          TYPE ZFIT079_ITEM-ERFME,
    WRBTR          TYPE ZFIT079_ITEM-WRBTR,
    WAERS          TYPE ZFIT079_ITEM-WAERS,
    MWSKZ          TYPE ZFIT079_ITEM-MWSKZ,
    ZFPSL          TYPE ZFIT079_ITEM-ZFPSL,
    ZFPSE          TYPE ZFIT079_ITEM-ZFPSE,
    MBLNR          TYPE ZFIT079_ITEM-MBLNR,
    MJAHR          TYPE ZFIT079_ITEM-MJAHR,
    ZEILE          TYPE ZFIT079_ITEM-ZEILE,
    SHEET_NO       TYPE ZFIT079_ITEM-SHEET_NO,
    COND_TYPE      TYPE ZFIT079_ITEM-COND_TYPE,

    BSART_AND_TEXT TYPE TEXT100,
    WERKS_AND_NAME TYPE TEXT100,
    CHARG          TYPE ZFIT079_ITEM-CHARG,
    MATNR          TYPE ZFIT079_ITEM-MATNR,
    TXZ01          TYPE ZFIT079_ITEM-TXZ01,
    SHKZG          TYPE ZFIT079_ITEM-SHKZG,

    T_COLOR        TYPE LVC_T_SCOL,
  END OF TY_UPLOAD_DATA,

  BEGIN OF TY_RESULT,
    LIGHT          TYPE ICONNAME, "信息灯列
    MSG            TYPE BAPIRET2-MESSAGE,

    ZHBBS          TYPE ZFIT078_HEAD-ZFPHM,
    ZFPHM          TYPE ZFIT078_HEAD-ZFPHM,
    JSDDH          TYPE ZFIT079_HEAD-JSDDH,
    JSDZT          TYPE ZFIT079_HEAD-JSDZT,
    ZHSJE          TYPE ZFIT078_HEAD-ZHSJE,
    ZHJSE          TYPE ZFIT078_HEAD-ZHJSE,
    ZHJSE_GX       TYPE ZFIT079_HEAD-ZHJSE_GX,
    ZBHSJE         TYPE ZFIT078_HEAD-ZBHSJE,
    ZBHSJE_GX      TYPE ZFIT079_HEAD-ZBHSJE_GX,
    SGTXT          TYPE ZFIT079_HEAD-SGTXT,

    LIFNR_AND_NAME TYPE TEXT100,
    ZYSFPHM        TYPE ZFIT079_ITEM-ZYSFPHM,
    EBELN          TYPE ZFIT079_ITEM-EBELN,
    EBELP          TYPE ZFIT079_ITEM-EBELP,

    ERFMG          TYPE ZFIT079_ITEM-ERFMG,
    ERFME          TYPE ZFIT079_ITEM-ERFME,
    WRBTR          TYPE ZFIT079_ITEM-WRBTR,
    BEZNK          TYPE ZFIT079_ITEM-BEZNK, "分摊的货款
    WAERS          TYPE ZFIT079_ITEM-WAERS,
    MWSKZ          TYPE ZFIT079_ITEM-MWSKZ,
    ZFPSL          TYPE ZFIT079_ITEM-ZFPSL,
    ZFPSE          TYPE ZFIT079_ITEM-ZFPSE,
    MBLNR          TYPE ZFIT079_ITEM-MBLNR,
    MJAHR          TYPE ZFIT079_ITEM-MJAHR,
    ZEILE          TYPE ZFIT079_ITEM-ZEILE,
    SHEET_NO       TYPE ZFIT079_ITEM-SHEET_NO,
    COND_TYPE      TYPE ZFIT079_ITEM-COND_TYPE,

    BSART_AND_TEXT TYPE TEXT100,
    WERKS_AND_NAME TYPE TEXT100,
    CHARG          TYPE ZFIT079_ITEM-CHARG,
    MATNR          TYPE ZFIT079_ITEM-MATNR,
    TXZ01          TYPE ZFIT079_ITEM-TXZ01,
    SHKZG          TYPE ZFIT079_ITEM-SHKZG,

    T_COLOR        TYPE LVC_T_SCOL,

  END OF TY_RESULT,

  BEGIN OF TY_GR_QUERY_RESULT. "Copy from ZFIU019 TY_GR_QUERY_RESULT.

    INCLUDE TYPE  ZFIT079_ITEM.
TYPES:
    LIFNR        TYPE EKKO-LIFNR,
    LIFNR_NAME   TYPE LFA1-NAME1,
    BUKRS        TYPE EKKO-BUKRS,
    BATXT        TYPE T161T-BATXT,
    WERKS_NAME   TYPE T001W-NAME1,
    MENGE        TYPE EKPO-MENGE,
    PO_AEDAT     TYPE EKKO-AEDAT,
    PO_ERNAM     TYPE EKKO-ERNAM,
    LGOBE        TYPE T001L-LGOBE,

    GL_HKONT_TXT TYPE SKAT-TXT20,
    GL_KOSTL_TXT TYPE CSKT-KTEXT,

    SELECT       TYPE C,   "选择
    FRMDB        TYPE C,   "来自行项目表
  END OF TY_GR_QUERY_RESULT.

DATA:
  GV_CHARG           TYPE EKBE-CHARG,
  GV_LICHA           TYPE MCH1-LICHA,  "供应商批次编号
  GS_MSG             TYPE BAPIRET2,
  GV_EBELN_EBELP     TYPE CHAR30,
  GV_POPUP_MSG       TYPE STRING,
  GV_POPUP_YES       TYPE C,
  "GV_SPLIT_NUMBER    TYPE I VALUE 450,   "多少条行项目需拆分
  GT_ZFIT078_HEAD    TYPE TABLE OF ZFIT078_HEAD,
  GT_INV_DATA        TYPE TABLE OF TY_INV_DATA WITH HEADER LINE,
  GT_GR_DATA         TYPE TABLE OF TY_GR_DATA WITH HEADER LINE,
  GT_UPLOAD_DATA     TYPE TABLE OF TY_UPLOAD_DATA WITH HEADER LINE,
  GT_GR_QUERY_RESULT TYPE TABLE OF TY_GR_QUERY_RESULT WITH HEADER LINE,
  GT_RESULT          TYPE TABLE OF TY_RESULT WITH HEADER LINE.

DATA:
  GR_TABLE     TYPE REF TO CL_SALV_TABLE.

CONSTANTS:
  GC_ZYWLX_DOMESTIC    TYPE ZFIT079_HEAD-ZYWLX VALUE '01',
  GC_ZYWLX_FOREIGN     TYPE ZFIT079_HEAD-ZYWLX VALUE '02',
  GC_ZYWLX_CONSIGNMENT TYPE ZFIT079_HEAD-ZYWLX VALUE '03',
  GC_JSDLX_PO          TYPE ZFIT079_HEAD-JSDLX VALUE '01',
  GC_JSDZT_DRAFT       TYPE ZFIT079_HEAD-JSDZT VALUE '01',
  GC_JSDZT_SUBMITED    TYPE ZFIT079_HEAD-JSDZT VALUE '02',
  GC_JSDZT_PROCESS     TYPE ZFIT079_HEAD-JSDZT VALUE '03',
  GC_JSDZT_DEPRECATED  TYPE ZFIT079_HEAD-JSDZT VALUE '04',
  GC_JSDZT_POSTED      TYPE ZFIT079_HEAD-JSDZT VALUE '05',
  GC_YWCL_INV          TYPE ZFIT079_HEAD-VORGANG VALUE '1',
  GC_YWCL_CRMO         TYPE ZFIT079_HEAD-VORGANG VALUE '2',
  GC_YWCL_SUBSD        TYPE ZFIT079_HEAD-VORGANG VALUE '3',
  GC_YWCL_SUBSC        TYPE ZFIT079_HEAD-VORGANG VALUE '4',
  GC_CONCAT_FLAG       TYPE C VALUE '-',
  GC_HB_FLAG           TYPE CHAR2 VALUE 'HB',
  GC_CF_FLAG           TYPE CHAR2 VALUE 'CF',
  GC_BATCH_TEMPL_NAME  TYPE WWWDATATAB-OBJID VALUE 'ZFIU021_TMPL'.

SELECTION-SCREEN: BEGIN OF BLOCK BLK1 WITH FRAME TITLE TEXT-T01.
  SELECT-OPTIONS:
    S_BUKRS FOR ZFIT078_HEAD-BUKRS OBLIGATORY NO INTERVALS NO-EXTENSION DEFAULT 'CN10',
    S_LIFNR FOR ZFIT078_HEAD-LIFNR,
    S_ZFPHM FOR ZFIT078_HEAD-ZFPHM,
    S_ZKPSJ FOR ZFIT078_HEAD-ZKPSJ,
    S_ZXFMC FOR ZFIT078_HEAD-ZXFMC.
SELECTION-SCREEN: END OF BLOCK BLK1.

SELECTION-SCREEN: BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-T02.
  SELECT-OPTIONS:
    S_BSART    FOR EKKO-BSART,
    S_EKGRP    FOR EKKO-EKGRP,
    S_EBELN    FOR EKKO-EBELN,
    S_EBELP    FOR EKBE-EBELP,
    S_EBENP    FOR GV_EBELN_EBELP NO INTERVALS,
    S_WERKS    FOR EKBE-WERKS,
    S_MATNR    FOR EKBE-MATNR,
    S_CHARG    FOR GV_CHARG,
    S_LICHA    FOR GV_LICHA,
    S_GJAHR    FOR EKBE-GJAHR NO INTERVALS NO-EXTENSION,
    S_BELNR    FOR EKBE-BELNR,
    S_ERNAM    FOR EKKO-ERNAM,
    S_AEDAT    FOR EKKO-AEDAT.

  SELECTION-SCREEN BEGIN OF LINE .
    PARAMETERS P_XWARE  AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN COMMENT 3(12) FOR FIELD P_XWARE.

    PARAMETERS P_XBNKQT  AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN COMMENT 18(18) FOR FIELD P_XBNKQT.

    PARAMETERS P_XBNKYF  AS CHECKBOX.
    SELECTION-SCREEN COMMENT 43(15) FOR FIELD P_XBNKYF.

    PARAMETERS P_ZBL  AS CHECKBOX.
    SELECTION-SCREEN COMMENT 60(18) FOR FIELD P_ZBL.

  SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN: END OF BLOCK BLK2.

SELECTION-SCREEN: BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-T05.
  SELECTION-SCREEN BEGIN OF LINE .
    PARAMETERS:
      P_AUTFT AS CHECKBOX DEFAULT 'X'.
    SELECTION-SCREEN COMMENT 3(20) FOR FIELD P_AUTFT.

    PARAMETERS P_QTYFT RADIOBUTTON GROUP R1 DEFAULT 'X' USER-COMMAND UCOMM1.
    SELECTION-SCREEN COMMENT 25(15) FOR FIELD P_QTYFT.

    PARAMETERS P_AMTFT   RADIOBUTTON GROUP R1.
    SELECTION-SCREEN COMMENT 42(15) FOR FIELD P_AMTFT.

  SELECTION-SCREEN END OF LINE.

  SELECTION-SCREEN BEGIN OF LINE .
    SELECTION-SCREEN COMMENT 1(31) FOR FIELD P_GLAMT.
    PARAMETERS:
      P_GLAMT TYPE ZFIT079_HEAD-ZBHSJE_CY.

    SELECTION-SCREEN COMMENT 70(25) FOR FIELD P_SPLNUM.
    PARAMETERS:
      P_SPLNUM TYPE NUMC3 DEFAULT 450.

  SELECTION-SCREEN END OF LINE.

  PARAMETERS:
  P_FILE  TYPE STRING.
SELECTION-SCREEN: END OF BLOCK BLK3.

SELECTION-SCREEN FUNCTION KEY 1 .
